home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / SCSI Samples 1.0 / SCSI Find Devices 06⁄15 ƒ / Src / SCSIFindDevicesMain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-16  |  1.9 KB  |  77 lines  |  [TEXT/KAHL]

  1. /*                                SCSIFindDevicesMain.c                            */
  2. /*
  3.  * SCSIFindDevicesMain.c
  4.  * Copyright © 1992-94 Apple Computer Inc. All Rights Reserved.
  5.  */
  6. /*
  7.  * This sample shows how to locate all attached SCSI devices.
  8.  */
  9. #include <Folders.h>
  10. #include <Errors.h>
  11. #include <stdio.h>
  12. #ifdef THINK_C
  13. #include <console.h>
  14. #endif
  15. #include "SCSIFindDevices.h"
  16.  
  17. SCSIFindDevicesRec            gSCSIFindDevicesRec;
  18.  
  19. void
  20. main(
  21. #ifdef THINK_C
  22.         int                    argc,
  23.         char                **argv
  24. #endif
  25.     )
  26. {
  27.         OSErr                status;
  28.         int                    devicesFound;
  29.         
  30. #ifdef THINK_C
  31.         argc = ccommand(&argv);
  32. #endif
  33.         /*
  34.          * Initialize the Find "global" area. If deviceID.bus is 0xFF, the
  35.          * find subroutine will initialize and return the first device.
  36.          * Set the maxLUN field to zero to prevent multiple LUN recognition
  37.          * or set it to seven to enable all LUNs.
  38.          */
  39.         gSCSIFindDevicesRec.deviceID.bus = 0xFF;
  40.         gSCSIFindDevicesRec.maxLUN = 7;
  41.         devicesFound = 0;
  42.         while ((status = SCSIFindNextDevice(&gSCSIFindDevicesRec)) == noErr) {
  43.             ++devicesFound;
  44.             if (gSCSIFindDevicesRec.isAsyncSCSIPresent) {
  45.                 printf("%d.%d.%d \"%.8s\" \"%.16s\"\n",
  46.                     (int) gSCSIFindDevicesRec.deviceID.bus,
  47.                     (int) gSCSIFindDevicesRec.deviceID.targetID,
  48.                     (int) gSCSIFindDevicesRec.deviceID.LUN,
  49.                     gSCSIFindDevicesRec.inquiry.vendor,
  50.                     gSCSIFindDevicesRec.inquiry.product
  51.                 );
  52.             }
  53.             else {
  54.                 printf("%d.%d \"%.8s\" \"%.16s\"\n",
  55.                     (int) gSCSIFindDevicesRec.deviceID.targetID,
  56.                     (int) gSCSIFindDevicesRec.deviceID.LUN,
  57.                     gSCSIFindDevicesRec.inquiry.vendor,
  58.                     gSCSIFindDevicesRec.inquiry.product
  59.                 );
  60.             }
  61.         }
  62.         if (status == eofErr)
  63.             printf("Normal completion, %d devices found\n", devicesFound);
  64.         else {
  65.             printf("Failure: system error %d after finding %d devices\n",
  66.                 (int) status,
  67.                 devicesFound
  68.             );
  69.         }
  70.         if (gSCSIFindDevicesRec.isAsyncSCSIPresent)
  71.             printf("Using asynchronous SCSI Manager\n");
  72.         else {
  73.             printf("Using original SCSI Manager only\n");
  74.         }
  75. }
  76.  
  77.